package com.xcity.game.buff.effect;

import com.xcity.db.entity.Player;
import com.xcity.game.buff.Buff;
import com.xcity.game.buff.BuffEffector;
import com.xcity.game.common.GameStaticConfig;
import com.xcity.game.common.PlayerPool;
import com.xcity.pomelo.push.SyncPush;
import com.xcity.pomelo.push.sync.IntSync;

/**
 * 减少建造点击cd
 * @author yang.li
 *
 */
public class ReduceBuildCDEffect implements BuffEffector {

	@Override
	public boolean effect(Buff buff, Player player) {
		int cd = buff.getTemplate().getParameter(0);
		if (cd > 0) {
			player.poolSet(PlayerPool.PROPERTY_BUILD_SPEED_UP_REDUCE_CD, cd * 1000);
			buff.addUsedTimes(1);
			player.send(new IntSync(SyncPush.SYNC_BUILD_SPEED, cd));
		}
		return true;
	}

	@Override
	public boolean uneffect(Buff buff, Player player) {
		player.poolRemove(PlayerPool.PROPERTY_BUILD_SPEED_UP_REDUCE_CD);
		player.send(new IntSync(SyncPush.SYNC_BUILD_SPEED, GameStaticConfig.speedUpReduceCD / 1000));
		return true;
	}

}
